package com.cskaoyan.market.controller.admin;

import com.cskaoyan.market.annotation.RequiresPermissionsDesc;
import com.cskaoyan.market.bo.CommentDeleteBo;
import com.cskaoyan.market.bo.CommonListBo;
import com.cskaoyan.market.db.domain.MarketComment;
import com.cskaoyan.market.service.AdminCommentService;
import com.cskaoyan.market.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/comment")
public class AdminCommentController {

    @Autowired
    AdminCommentService adminCommentService;

    @GetMapping("list")
    @RequiresPermissions("admin:comment:list")
    @RequiresPermissionsDesc(menu = {"商场管理", "评论管理"},button = "查询")
    public Object list(CommonListBo commonListBo)  {
        List<MarketComment> marketGoodsList = adminCommentService.list(commonListBo);
        return ResponseUtil.okList(marketGoodsList);
    }


    @PostMapping("delete")
    @RequiresPermissions("admin:comment:delete")
    @RequiresPermissionsDesc(menu = {"商场管理", "评论管理"},button = "删除")
    public Object delete(@RequestBody CommentDeleteBo commentDeleteBo)  {
        adminCommentService.delete(commentDeleteBo.getId().toString());
        return ResponseUtil.ok();
    }
}
